package dk.henrikkleist.knrradio;

import android.app.Service;
import android.content.Intent;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.IBinder;
import android.util.Log;
import android.widget.Toast;

public class RadioService extends Service{
	private static final String TAG = "RadioService";
	private final static String RADIO_STATION_URL = "http://194.177.250.14:8000/";
	MediaPlayer player;
	
	@Override
	public IBinder onBind(Intent intent) {
		return null;
	}
	
	@Override
	public void onCreate() {
		Toast.makeText(this, "KNR Radio service er oprettet", Toast.LENGTH_LONG).show();
		Log.d(TAG, "onCreate");
		
		player = MediaPlayer.create(this, Uri.parse(RADIO_STATION_URL));
	}
	
	@Override
	public void onDestroy() {
		Toast.makeText(this, "KNR Radio er stoppet", Toast.LENGTH_LONG).show();
		Log.d(TAG, "onDestroy");
		player.stop();
	}
	
	@Override
	public void onStart(Intent intent, int startid) {
		Toast.makeText(this, "KNR Radio er startet", Toast.LENGTH_LONG).show();
		Log.d(TAG, "onStart");
		player.start();
	}
}
